package com.lmk;

import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {

        double[] scores=new double[3];
       // 可以通过索引访问数据元素  索引是从0开始的自然整数
        scores[0]=78.0;
        scores[1]=77.0;//
        scores[2]=76.1;
        //数组的遍历
        for (int i = 0; i <scores.length; i++) {
            System.out.println(scores[i]);
        }
        System.out.println("============");
        //for-each 循环 增强的for循环   特点语法简洁 缺点无法获得当前的索引值
        for (double s:scores){
            System.out.println(s);
        }
        int[] a={8,4,2,1,23,344,12};
        for (int s:a
             ) {
            System.out.print(s+"   ");
        }
        int sum=0;
        for (int i:a) {
           sum+=i;
        }
        System.out.println("该数组数字之和"+sum);
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个整数");
        int d=sc.nextInt();
       for (int i:a){
           if (d==i){
               System.out.println("存在该数");
           }

       }

       } {
        System.out.println("不存在该是");
    }}



